class User < ApplicationRecord
  validates :username, presence: { message: "kkk"}
  validates :password, length: {minimum: 6}
  validates :password, presence: {message: "aaaa"}
  validates :username, uniqueness: {message: "kill"}
  validates :validate_password, on: :create
  before_save :update_password

  attr_accessor :password
  attr_accessor :password_confimation

  # after_save //other model
  # create,update,destroy,find,find_by,find_by!,where
  # delete,

  # scope :admin, ->{ where.not(ddb_account_id: nil) }
  # scope :staff, ->{ where(ddb_account_id: nil)}

  scope :delete, ->{ where(:id => 2)}





  private
    def update_password
      self.password = self.password.upcase
    end

    def validate_password
      if self.password.blank?
        return false
      end

    end
end

